import { createRouter, createWebHashHistory } from 'vue-router'
import Main from '@/views/Main.vue'

export const routes = [
  {
    path: '/',
    name: 'main',
    component: Main,
    meta: {
      hidden: true
    },
    children: [
      {
        path: '/user/index',
        name: 'UserIndex',
        component: () => import('@/views/Users/index.vue')
      }
    ]
  },
  {
    path: '/404',
    component: () => import('@/views/Error/404.vue'),
    name: 'NoFind',
    meta: {
      hidden: true,
      title: '404',
      noTagsView: true
    }
  },

  {
    path: '/:path(.*)*',
    redirect: '/404',
    name: '404Page',
    meta: {
      hidden: true,
      breadcrumb: false
    }
  },
  {
    path: '/demo',
    name: 'demo',
    component: Main,
    meta: {
      hidden: true
    },
    children: [
      {
        path: 'form',
        name: 'demo-form',
        component: () => import('@/views/Demos/Form')
      }
    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export function setupRouter(app) {
  app.use(router)
}
export function useRouter() {
  return router
}
export default router
